package logic

import (
	"context"
	"house_srv/house_srv"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FindHouseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFindHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindHouseLogic {
	return &FindHouseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FindHouseLogic) FindHouse(req *types.FindHouseRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	house, err := l.svcCtx.HouseSrv.FindHouse(l.ctx, &house_srv.FindHouseRequest{Id: int64(req.HouseId)})
	if err != nil {
		return &types.Response{
			Message: "查找失败",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "查找成功",
		Code:    200,
		Data:    house,
	}, nil
}
